package com.wlw.equipment.controller;

import com.wlw.equipment.pojo.PageResult;
import com.wlw.equipment.pojo.RequestParams;
import com.wlw.equipment.service.IEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 设备控制层
 *
 * @author lutianqi
 * @date 2022/5/26 15:45
 */
@RestController
@RequestMapping("/equipment")
public class EquipmentController {

    @Autowired
    private IEquipmentService equipmentService;

    @PostMapping("/list")
    public PageResult search(@RequestBody RequestParams requestParams) throws IOException {
        System.out.println("RestController"+"-----------search");
        return equipmentService.search(requestParams);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestParams requestParams) throws IOException {
        System.out.println("RestController"+"----------getFilters");
        return equipmentService.filters(requestParams);
    }

    @GetMapping("/suggestion")
    public List<String> getSuggestions(@RequestParam("key") String prefix) {
        System.out.println("RestController"+"---------getFilters");
        return equipmentService.getSuggestions(prefix);
    }

}
